package com.veer.shop.controller.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.veer.shop.annotation.ApiControllerLog;
import com.veer.shop.annotation.ApiSecured;
import com.veer.shop.config.ApiUrlConfig;
import com.veer.shop.param.TagParam;
import com.veer.shop.pojo.ProductTag;
import com.veer.shop.pojo.ResponseData;
import com.veer.shop.service.impl.admin.TagServiceImpl;

/**
 * 商品标签  控制器
 * 
 * @author Wangbin
 * 2020年9月22日-下午5:52:04
 */
@RestController
public class TagController {
	
	@Autowired
	private TagServiceImpl productTagServiceImpl;
	
	/**
	 * 获取商品标签列表
	 */
	@ApiSecured
	@ApiControllerLog(description = "获取商品标签列表")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_TAG_LIST_URL, method = RequestMethod.GET)
	public ResponseData<?> getList(@RequestBody(required = false) TagParam tagListParam, @RequestParam(required = false, name = "page_no", defaultValue = "1")Integer pageNo, @RequestParam(required = false, name = "page_size", defaultValue = "20")Integer pageSize)
	{
		return productTagServiceImpl.getAll(tagListParam, pageNo, pageSize);
	}
	
	/**
	 * 新增|更新商品标签
	 */
	@ApiSecured
	@ApiControllerLog(description = "新增|更新商品标签")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_TAG_UPDATE_URL, method = RequestMethod.POST)
	public ResponseData<?> update(@RequestBody ProductTag tag)
	{
		return productTagServiceImpl.update(tag);
	}
	
	/**
	 * 删除商品标签
	 */
	@ApiSecured
	@ApiControllerLog(description = "删除商品标签")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_TAG_DELETE_URL, method = RequestMethod.POST)
	public ResponseData<?> delete(@RequestParam(name = "tag_id", defaultValue = "") String tagId)
	{
		return productTagServiceImpl.delete(tagId);
	}
	
	/**
	 * 商品标签详情
	 */
	@ApiSecured
	@ApiControllerLog(description = "商品标签详情")
	@RequestMapping( path = ApiUrlConfig.API_PRODUCT_TAG_GET_URL, method = RequestMethod.GET)
	public ResponseData<?> get(@RequestParam(name = "tag_id", defaultValue = "")Integer tagId)
	{
		return productTagServiceImpl.get(tagId);
	}
}
